package com.the.ui.page.fragment

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.theone.mvvm.base.viewmodel.BaseViewModel
import com.theone.mvvm.core.base.fragment.BaseCoreFragment
import com.the.ui.R
import com.the.ui.databinding.FragmentGroupListViewBinding
import com.the.ui.page.fragment.photoview.PhotoViewListFragment
import com.the.ui.page.fragment.textview.ColorTrackTextViewFragment
import com.theone.mvvm.ext.qmui.addToGroup
import com.theone.mvvm.ext.qmui.createItem

//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛
/**
 * @author The one
 * @date 2021-11-03 16:44
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
class IndexFragment : BaseCoreFragment<BaseViewModel, FragmentGroupListViewBinding>(),
    View.OnClickListener {

    lateinit var mPhotoView: QMUICommonListItemView
    lateinit var mColorTrackTextView: QMUICommonListItemView
    lateinit var mFlowLayout: QMUICommonListItemView
    lateinit var mSlideCard: QMUICommonListItemView

    override fun isExitPage(): Boolean = true

    override fun initView(root: View) {
        getTopBar()?.setTitle(R.string.app_name)
        mBinding.groupListView.run {
            mPhotoView = createItem(R.string.photo_view)
            mColorTrackTextView = createItem(R.string.color_track_text_view)
            mFlowLayout = createItem(R.string.flow_layout)
            mSlideCard = createItem(R.string.slide_card)
            addToGroup(mPhotoView,mColorTrackTextView,mFlowLayout,mSlideCard, title = "", listener = this@IndexFragment)
        }
    }

    override fun createObserver() {

    }

    override fun onClick(v: View?) {
        startFragment(
            when (v) {
                mColorTrackTextView -> ColorTrackTextViewFragment()
                mFlowLayout -> FlowLayoutFragment()
                mSlideCard -> SlideCardFragment()
                else -> {
                    PhotoViewListFragment()
                }
            }
        )
    }

}